home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / PacMan / Monster.h < prev    next >
Encoding:
Text File  |  1992-07-24  |  2.1 KB  |  69 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. // This object moves and renders the Ghosts that chase and kill you.
  5.  
  6. #import "GameActor.h"
  7.  
  8.  
  9. typedef int intm[8];    // used in the arrays to control movement of ghosts
  10.  
  11. // valid states for a ghost
  12. #define HOVER    0
  13. #define CHASE    1
  14. #define RUN        2
  15. #define HOME    3
  16.  
  17. #define HARMLESS 2    // return value for munch (YES/NO/HARMLESS)
  18.  
  19. // ghost colors (for "myColor" instance variable)
  20. #define BLUE_GHOST        0
  21. #define GREEN_GHOST        1
  22. #define ORANGE_GHOST    2
  23. #define PURPLE_GHOST    3
  24. #define INVISIBLE_GHOST    4
  25. #define GHOST_EYES        5
  26.  
  27. // power dot states
  28. #define DOT_NONE    0
  29. #define DOT_EATEN    1
  30. #define DOT_FADING    2
  31.  
  32. @interface Monster:GameActor
  33. {
  34.     id    player;        // This is who we chase
  35.     id    maze;        // This is where we are
  36.     id  ghosts;        // The tiff of the ghost images
  37.     
  38.     BOOL eatable;    // Can we be eaten ??
  39.     int powerState;    // what's the power dot state
  40.     int powerTime;    // how long power dot's been on
  41.     int state;        // what we're doing
  42.     int fix;        // fix flag for hovering movement
  43.     int loops;        // number of times we've circled around in the ghost box
  44.     
  45.     int img;        // which animation frame to use
  46.     int myColor;    // which ghost (0-3) am I?
  47.     
  48. }
  49.  
  50. - init;    // Calls method below with semi-sane values...but you should use below:
  51. - initGhost:(int)num player:(id)pac maze:(id)world at:(int)sx :(int)sy;
  52.     // designated initializer; initializes all the ghosts.
  53. - renderAt:(int)posx :(int)posy move:(BOOL)moveOk;    // draw ghost...
  54.     // lockfocus in the view where it's drawn first.
  55. - move:sender;            // decide where to move the ghost for the next frame
  56. - powerDot:(BOOL)eat;    // called when power dots are eaten or run out.
  57. - (BOOL)canBeEaten;        // returns "eatable".
  58. - (int)munch;            // called when pac intersects ghost
  59.  
  60. // These four methods handle actual movement.  They are internal, and generally
  61. // called by the (-move:) method.  You shouldn't ever use them directly!
  62. - hover;            // hover moves solid ghost when in ghost chamber
  63. - runAway;            // ghost runs away at 1/2 speed after power pill
  64. - chase;            // ghost chases player down
  65. - goHome;            // used to make the eyes run to ghost chamber at 2x speed
  66. - moveOneFrame;        // makes the animation advance one step.
  67.  
  68. @end
  69.